

// Account.java
// Represents a bank account

public class Account 					
{
   private double interest; //interest on account
   private String type; // the account type
   private int accountNumber; // account number
   private double availableBalance; // funds available for withdrawal
   private double totalBalance; // funds available + pending deposits
   private double interestBalance; // balance with simulated interests
   
   private static final String KASSEKREDIT = "Kassekredit";
   private static final String OPSPARING = "Opsparing";
   

   // Account constructor initializes attributes
   public Account(String theType, int theAccountNumber, double theAvailableBalance, double theTotalBalance )
   {
      type = theType;
	  accountNumber = theAccountNumber;
      availableBalance = theAvailableBalance;
      totalBalance = theTotalBalance;
      
      interestBalance = 0;
      
     if (type.equals(KASSEKREDIT))
     {
    	 interest = 0.06; // interest on kassekredit accounts
     }
     else if (type.equals(OPSPARING))
     {
    	 interest = 0.02; // interest on opsparings accounts
     }
   } // end Account constructor
   
   // simulate the interest balance
   public void setInterest(int year)
   {
	   interestBalance  = totalBalance * Math.pow(1+interest, year);
   } // end method setInterest
   
   // returns the balance with simulated interest
   public double getInterest()
   {
	   return interestBalance;
   } // end method getInterest

   // returns available balance
   public double getAvailableBalance()
   {
      return availableBalance;
   } // end getAvailableBalance

   // returns the total balance
   public double getTotalBalance()
   {
      return totalBalance;
   } // end method getTotalBalance

   //adds transfered amount to account
   public void transfer(double amount)
   {
	   availableBalance += amount; // add to available balance
	   totalBalance += amount; // add to total balance
   } // end method transfer
   
   // credits an amount to the account
   public void credit( double amount )
   {
      totalBalance += amount; // add to total balance
   } // end method credit

   // debits an amount from the account
   public void debit( double amount )
   {
      availableBalance -= amount; // subtract from available balance
      totalBalance -= amount; // subtract from total balance
   } // end method debit

   // returns account number
   public int getAccountNumber()
   {
      return accountNumber;  
   } // end method getAccountNumber
   
   // returns account name
   public String getType()
   {
	   return type;
   } // end method getAccountName

} // end class Account
